package org.biliviz.be.service.impl;

import org.biliviz.be.entity.VtScoreLfc;
import org.biliviz.be.entity.VtScoreTop;
import org.biliviz.be.mapper.VtScoreLfcMapper;
import org.biliviz.be.service.VtScoreLfcService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

import java.util.Comparator;
import java.util.List;
import java.util.stream.Collectors;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author sg
 * @since 2024-02-20
 */
@Service
public class VtScoreLfcServiceImpl extends ServiceImpl<VtScoreLfcMapper, VtScoreLfc> implements VtScoreLfcService {
    @Override
    public List<VtScoreLfc> getAll() {
        List<VtScoreLfc> vtScoreLfc = baseMapper.selectList(null);
        vtScoreLfc.sort(Comparator.comparingInt(VtScoreLfc::getTotalScore).reversed());
        return vtScoreLfc;
    }

    @Override
    public List<VtScoreLfc> getLifeSLFC() {

        List<VtScoreLfc> lifeSLFC = baseMapper.selectList(null)
                .stream()
                .filter(item -> "生活".equals(item.getChannel()))  // 添加判断条件
                .sorted(Comparator.comparingInt(VtScoreLfc::getTotalScore).reversed())  // 排序
                .collect(Collectors.toList());  // 将结果收集为列表
        return lifeSLFC;
    }

    @Override
    public List<VtScoreLfc> getChannelLFC(String channel) {
        List<VtScoreLfc> channelSLFC = baseMapper.selectList(null)
                .stream()
                .filter(item -> channel.equals(item.getChannel()))  // 添加判断条件
                .sorted(Comparator.comparingInt(VtScoreLfc::getTotalScore).reversed())  // 排序
                .collect(Collectors.toList());  // 将结果收集为列表
        return channelSLFC;
    }


}
